﻿using System;

namespace NRank.Benchmark.Benchmarking
{
	/// <summary>
	/// StopWtach provides methods for time measuring.
	/// </summary>
	public static class StopWatch
	{
		/// <summary>
		/// Measuring start time
		/// </summary>
		private static DateTime startTime;

		/// <summary>
		/// Starts measuring
		/// </summary>
		public static void Start()
		{
			startTime = DateTime.Now;
		}

		/// <summary>
		/// Stops measuring and updates start time
		/// </summary>
		/// <param name="k"></param>
		/// <param name="algorithmName"></param>
		/// <returns></returns>
		public static BenchmarkResult Measure(int k, string algorithmName, int leftDepth, int rightDepth)
		{
			var stopTime = DateTime.Now;

			var timeConsumed = stopTime - startTime;

			startTime = stopTime;

			return new BenchmarkResult(k, timeConsumed, algorithmName, leftDepth, rightDepth);
		}
	}
}